<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function Parent() {
        this.chrldrens = ['zs', 'ls', 'ww']
      }
      Parent.prototype.sayHi = function () {
        console.log('Hi!')
      }
      function Child() {
        Parent.call(this)
      }
      Child.prototype = new Parent()
      const child1 = new Child()
      const child2 = new Child()

      // console.log(child1.chrldrens)
      child2.chrldrens = [1, 2, 3]
      console.log(child1.chrldrens, child2.chrldrens)

      child1.sayHi()

      // 组合继承的缺点：存在代码重复问题。
    </script>
  </body>
</html>
